# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
#   cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
#   Mayor.create(name: 'Emanuel', city: cities.first)
unless Rails.env.production?
  Admin.destroy_all
  Role.destroy_all
  role = Role.create(name: 'Super admin')
  Permissions.each { |p| Permission.create action: p }
  Permission.all.each do |permission|
    role.grants.create(permission: permission)
  end
  Admin.create(email: 'super@vic.com', password: '1q2w3e4r5t', name: 'zhoumh', role: role)

  UserGroup.find_or_create_by(name: 'Default')
end
